package com.sanley.piss.mapper;


import com.sanley.piss.model.BaseMapper;
import com.sanley.piss.model.po.RoleAndResourceRelation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.util.List;

/**
 * Create By  on 2021/3/9.
 * @author 张凯大天才
 */
@Mapper
public interface RoleAndResourceRelationMapper extends BaseMapper<RoleAndResourceRelation> {
    /**
     * 删除单条数据
     * @param roleId
     * @return
     */
    @Delete("delete from t_system_role_resource_relation where role_id=#{roleId}")
    int deleteByRoleId(Serializable roleId);

    /**
     * 根据角色Id 查询 资源ID
     * @param roleId
     * @return
     */
    @Select("select role_id,resource_id from t_system_role_resource_relation where role_id=#{roleId} ")
    List<RoleAndResourceRelation> selectListByRoleId(Integer roleId);

    int removeByIds(@Param("roleId") Integer roleId, @Param("ids") Integer[] ids);

    RoleAndResourceRelation selectAll(@Param("roleId") Integer roleId, @Param("resourceId") Integer resourceId);
}
